﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LLFM.CAT.Model;
using LLFM.CAT.Service;
using Common;

public partial class Admin_Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpContext.Current.Session[Common.CommonConfig.AdminSessionString] = null;
    }

    protected void LoginCommand(object sender, EventArgs e)
    {
        string name = txtUserName.Value.Trim();
        string passWord = txtPassword.Value.Trim();
        if (name == string.Empty)
        {
            WebAlert.Alert("用户名为空");
        }
        else if (passWord == string.Empty)
        {
            WebAlert.Alert("密码为空");
        }
        else
        {
            M_User user = UserService.GetUserByPassWordAndNameAndIsAdmin(passWord, name, true,1);
            if (user != null)
            {
                HttpContext.Current.Session[Common.CommonConfig.AdminSessionString] = user;
                Response.Redirect("~/admin/product/ProductList.aspx");
            }
            else
            {
                WebAlert.Alert("用户名或密码不正确");
            }
        }
    }
}